<?php

require_once 'classes/LightPressPlugin.php';

class Flickr extends LightPressPlugin {
    
    var $constructor_args = array(
        'flickr_id'=>'Your Flickr id',
        'count'=>'How many pictures to display',
        'style'=>'Display style:  "random" or "latest"'
        );
    var $default_context = LP_CONTEXT_INDEX;
    var $description = 'Displays your Flickr badge';
    
    var $active = true;
    var $hooks = array('sidebar');
    
    var $flickr_id = '37842628@N00';
    var $count = '2';
    var $style = 'random';
    
    function Flickr(&$frontend, $args, $dummy_run=false) {
        $this->LightPressPlugin($frontend, $args, $dummy_run);
    }
    
    function run($hook, &$payload) {
        $tpl =& $this->_frontend->tpl;
        if (!file_exists(implode(DIRECTORY_SEPARATOR, array($tpl->root, 'plugins', 'flickr.xml')))) {
            $tpl->setVar('PLUGIN_FLICKR', '
                <h2>Flickr Photos</h2>
                <div class="ul" style="margin-top: 0.25em;">
                <script type="text/javascript" src="http://www.flickr.com/badge_code.gne?nsid=' . $this->flickr_id
                . '&count=' . $this->count . '&display=' . $this->style . '&name=0&size=square&raw=1"></script>
                </div>');
        } else {
            $tpl->setFile('plugin_flickr', 'plugins/flickr.xml');
            $tpl->setVar('plugin_flickr_id', $this->flickr_id);
            $tpl->setVar('plugin_flickr_count', (int) $this->count);
            $tpl->setVar('plugin_flickr_style', $this->style);
            $tpl->parse('PLUGIN_FLICKR', 'plugin_flickr');
        }
    }
}

?>